namespace SimpleWebServices.Web.UI.Html.Elements
{
    using System.Xml.Serialization;
    using SimpleWebServices;
    using Xunit;

    public sealed class CellAlignmentFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(new ObjectExpectations<CellAlignment>()
                .DerivesFrom<InnerElements>()
                .IsAbstractBaseClass()
                .Result);
        }

        [Fact]
        public void ctor()
        {
            Assert.NotNull(new TestCellAlignment() as CellAlignment);
        }

        [Fact]
        public void prop_Alignment()
        {
            Assert.True(new PropertyExpectations(typeof(TestCellAlignment).GetProperty("Alignment"))
                .IsAutoProperty<string>()
                .Result);
        }

        [Fact]
        public void prop_Character()
        {
            Assert.True(new PropertyExpectations(typeof(TestCellAlignment).GetProperty("Character"))
                .IsAutoProperty<string>()
                .Result);
        }

        [Fact]
        public void prop_CharacterOffset()
        {
            Assert.True(new PropertyExpectations(typeof(TestCellAlignment).GetProperty("CharacterOffset"))
                .IsAutoProperty<string>()
                .Result);
        }

        [Fact]
        public void prop_VerticalAlignment()
        {
            Assert.True(new PropertyExpectations(typeof(TestCellAlignment).GetProperty("VerticalAlignment"))
                .IsAutoProperty<string>()
                .Result);
        }

        [Fact]
        public void op_Deserialize_string_string_string()
        {
            CellAlignment expected = new TestCellAlignment
            {
                Id = "id",
                Class = "class",
                Language = "fr",
                Title = "title",
                Alignment = "left",
                Character = "x",
                CharacterOffset = "2",
                VerticalAlignment = "middle"
            };

            string xml =
                "<test" +
                " id='id'" +
                " class='class'" +
                " lang='fr'" +
                " title='title'" +
                " align='left'" +
                " char='x'" +
                " charoff='2'" +
                " valign='middle'" +
                "/>";
            CellAlignment actual = new TestCellAlignment().Deserialize("test", null, xml) as CellAlignment;

            Assert.Equal<string>(expected.ToString(), actual.ToString());
        }
    }
}